<?php
class MyMap
{
    private $map_width;         // Kartenbreite
    private $map_height;        // Kartenhöhe
    private $field_width_px;    // Breite eines Feldes in Pixel
    private $field_height_px;   // Höhe eines Feldes in Pixel
 
    public function setSize($width, $height)
    {
        $this->map_width = intval($width);
        $this->map_height = intval($height);
    }
    public function setFieldSize($width_px, $height_px)
    {
        $this->field_width_px = intval($width_px);
        $this->field_height_px = intval($height_px);
    }
    public function getHtml()
    {
        $code = '<div id="mymap">';
        for($y=0; $y < $this->map_height; $y++)
        {
            for($x=0; $x < $this->map_width; $x++)
            {
                $code .= '<div style="float: left; width: '.($this->field_width_px-1).'px; height: '.($this->field_height_px-1).'px; margin-right: 1px; margin-bottom: 1px; background-color: #009933; text-align: center;">('.$x.'|'.$y.')</div>';
            };
            $code .= '<div style="clear:both;"></div>';
        };
        $code .= '</div>';
        return $code;
    }
    public function show()
    {
        echo $this->getHtml();
    }
};
?>
